<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>欢迎登录选课系统</title>
  <style type="text/css">
    body{
    background-image: url("http://localhost:8080/my_term_project_xuanke/resource/image/image1.jpg");
    background-size:cover;
    }
    span{
    font-family:微软雅黑;
    color:black;
    font-size:25px;
    }
    li1{
    font-family:楷体;
    color:black;
    font-size:17px;
    line-height:20px;
    }
    td{
	font-family:黑体;
	color:black;
	font-size:18px;
    }
	li2{
	font-family:微软雅黑;
	color:black;
	font-size:15px;
	}
    li3{
	font-family:华文中宋;
	color:black;
	font-size:15px;
	}
	button{
	font-family:黑体;
	font-size: 16px;
	text-align: center;
	background-color: blue;
	border: 10px;
	color: white;
	padding: 5px 10px;
	display: inline-block;
	 }
	.btn_2k3{
	font-family:黑体;
	font-size: 16px;
	text-align: center;
	background-color: red;
	border: 10px;
	color: white;
	padding: 5px 10px;
	display: inline-block;
	 }
	 div1{
	 font-family:微软雅黑;
	 font-size: 16px;
	 }
 </style>
		<%
		String message=String.valueOf((request.getSession().getAttribute("loginmessage")));
		%>
		<script>
		var message="<%=message%>";
		if(message.length!=0&&message!="null"){
			alert(message);
			
		}
		<% request.getSession().setAttribute("loginmessage","");%>
		</script>
		 <%// 生成验证码
			    String code="";
				String codes []={"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
		        int len=codes.length;
		        int l=0;
		        while(l<6) {
		        	int m=(int) (Math.random()*len);
		        	code=code+codes[m];
		        	l++;
		        	}
			    %>
			     <script>
			    function validateLogin(){
			    	var Id=document.forms["LoginFrom"]["Id"].value;
					var password=document.forms["LoginFrom"]["Pwd"].value;
					var yzm=document.forms["LoginFrom"]["yzm"].value;
					var yzcode=document.getElementById("yzmcode").innerHTML;
					console.log("运行validate");
					console.log(yzcode);
			        if (Id ==""){
			         alert("请输入用户名!");
			         return false;
			        }
			       
			        else if (password ==""){
			         alert("请输入密码!");
			         return false;
			        }
					
					else if(yzm!=yzcode){
			       		alert("验证码错误");
			       		return false;
			        }    
			    }
			  
			    </script>
	</head>
	<body>
		<div class="logintop">    
		    <span>欢迎登录选课系统</span>    
		    <ul>
		    <li1><a href="http://localhost:8080/my_term_project_xuanke/login/login.jsp">是学生？</a></li1><br>
		    <li1><a href="http://localhost:8080/my_term_project_xuanke/login/help.jsp">帮助</a></li1><br>
		    <li1><a href="http://localhost:8080/my_term_project_xuanke/login/about.jsp">关于</a></li1><br>
		    </ul>    
		    </div>
		    	   
		    <form method="POST" name="LoginFrom" onsubmit="return validateLogin()" action="http://localhost:8080/my_term_project_xuanke/loginServlet?action=login"   ><!--  -->
			    <table>
			    <tr>
				    <td>&nbsp;&nbsp;&nbsp;&nbsp;账&nbsp;&nbsp;&nbsp;号：</td>
				    <td><input name="Id" type="text" placeholder="请输入账号"></td>
			    </tr>
			    <tr>
				    <td>&nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;&nbsp;&nbsp;码：</td>
				    <td><input name="Pwd" type="password" placeholder="请输入密码"/></td>
			    </tr>
			  
			    <tr>
				    <td>&nbsp;&nbsp;&nbsp;&nbsp;验 证 码：</td>
				    <td><input name="yzm"  placeholder="请输入验证码" type="text" value="<%=code%>"/></td>
				    <td><p id="yzmcode"><%=code%></p></td>
			    </tr>
			    
			  	 </table>
			  	 <ul> 
				     <li2><input name="remember_password" type="checkbox" value="" checked="checked" /><font color="0">保存密码</font></li2><br>
				  	 <li3><input type="radio" name="who" value="student" checked="checked">学生
								<input type="radio" name="who" value="admin">管理员</li3>
				  	 <li><button  type="submit" onclick="validateLogin()">提交</button>
				  	     <input name="cancel" type="reset" class="btn_2k3" value="重置"/></li>
			    </ul>
			    </form>
		   <div1>
			   <a href="http://localhost:8080/my_term_project_xuanke/login/updatePW.jsp"><font color=red>忘记密码？</font></a><br>
		   				    
		</div1>
			    <div1 class="loginbm">版权所有  <a href="">www.swufe.com</a>  仅供西南财经大学选课使用  </div1>
	</body>
</html>